package com.bokee.archerwq.lab.pattern.chainofresponsibility;

/**
 * Chain of Responsibility & Template Method
 * 
 * @author Rodney
 * 
 */
public abstract class Handler {

	protected Handler handler;

	public Handler(Handler handler) {
		this.handler = handler;
	}

	public void handleRequest(Action action) {
		before();
		if (handler != null) {
			handler.handleRequest(action);
		} else {
			action.run();
		}
		after();
	}

	protected abstract void before();

	protected abstract void after();
}
